<?php
namespace app\app\controller;

use app\common\controller\App;
use think\Db;
use think\Exception;


class Message extends App
{
    protected $middleware = ['AppAuth'];

    //我的消息
    public function my_message()
    {
        $page=request()->param("page",'1','intval');
        $uid=$this->getLoginUid();
        $message=model("Message")
            ->where(['uid'=>$uid])
            ->page($page,8)
            ->select()->each(function ($item){
                $item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
            });
        return $this->ok('请求成功',$message);
    }

    //删除消息
    public function del_message()
    {
        $id=request()->param('id','0','intval');
        $uid=$this->getLoginUid();
        $res=model("Message")->where(['uid'=>$uid,'id'=>$id])->delete();
        if ($res){
            return $this->ok('删除成功');
        }else{
            return $this->fail('删除失败');
        }

    }

}
